import 'babel-polyfill'
import Vue from 'vue';
import iview from 'iview';
import {router} from './router/index';
import store from './store';
import App from './app.vue';
import Cookies from 'js-cookie';

import 'iview/dist/styles/iview.css';
import './styles/credit-icon/iconfont.js';
import meunUtils from './tool/MenuUtils';
import VTable from '@/components/VTable/VTable';
import VFilter from '@/components/VFilter/VFilter';

Vue.use(iview);
Vue.component('VTable', VTable);
Vue.component('VFilter', VFilter);
// Vue.use(VueMce);

new Vue({
	el: '#app',
	router: router,
	store: store,
	render: h => h(App),
	data: {
		currentPageName: ''
	},
	mounted() {
		this.currentPageName = this.$route.name;
		// 显示打开的页面的列表
		this.$store.commit('setOpenedList');
		this.$store.commit('initCachepage');
		// iview-admin检查更新
		// util.checkUpdate(this);
	},
	created() {
		// store 更新, 权限控制
		let _menuInfo = window.localStorage.getItem('flc_plamenuInfo');
		let _sid = Cookies.get('flc_sid');
		if (_menuInfo && _sid) {
			let _router = meunUtils(JSON.parse(_menuInfo));
			this.$router.addRoutes(_router);
			
			this.$store.commit('updateMenulist');
			this.$store.commit('updateBtnsID');
		}
	}
});
